package cn.oowoo.smartdoc.entity;

import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.*;
import java.util.List;

/**
 * JSR303TestDTO
 */
@Data
public class JSR303TestDTO {
    public interface Update{};
    public interface Add{}

    /**
     * id
     */
    @NotNull(message = "id不能为空",groups = Update.class)
    @Null(groups = Add.class,message = "id必须为空")
    private Integer id;
    /**
     * 姓名
     */
    @NotBlank(groups = Add.class)
    @Size(min = 2,max = 8,message = "姓名必须是2-8位长度",groups = {Update.class,Add.class})
    private String name;
    /**
     * 年龄
     */
    @NotNull(groups = Add.class)
    @Range(min=18,max=150,message = "年龄必须在18-150岁之间",groups = {Update.class,Add.class})
    private Integer age;
    /**
     * 手机号码
     */
    @NotBlank(groups = Add.class)
    @Pattern(regexp = "^((17[0-9])|(14[0-9])|(13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$",message = "手机号码不合法",groups = {Update.class,Add.class})
    private String phone;
    /**
     * 邮箱
     */
    private String email;

    /**
     * 子节点
     */
    private List<JSR303TestDTO> children;
    /**
     * 用户信息
     */
    private UserDTO userDTO;
    /**
     * 忽略的字段
     * @ignore
     */
    private String ignoreTest;
    /**
     * total
     * @required
     */
    private Long total;

}
